$(document).ready(function(){
	var contextPath = document.location.pathname;
	var index = contextPath.substr(1).indexOf("/");
	contextPath = contextPath.substr(1, index);
	var basePath = "/" + contextPath;
	var openClose=0;
	/**定时器定时重新获取短信验证码*/
	var second = 90;
	var time = 1000; 
	var interval; //调度器对象。
	hideMobile();
		var validObject = $("#confirmForm").Validform({
			
			dataType:'text',
			tiptype:2,
			ajaxPost:true,
			
			callback:function(data){
				if(data==0){
					window.location.assign(basePath+"/HRTWEB/forgetPass/resettingSuccess.jsp");
				}else if(data==1){
					alert("手机验证输入错误，请重新输入");
				}
				else{
					alert("两次输入密码不一致！");
				}
			},
			
			tiptype:function(msg,o,cssctl){
				
				if(!o.obj.is("form")){
					var tds=o.obj.text();
					
					var objtip=o.obj.siblings(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				
					
				}	
				
			}
		
		});
		
	
	
	/**
	 * 获取验证码
	 */
	$("#confirmForm").delegate(
			'#validateBtn',
			'click',
			function(){
				alert("alert------");
				getMobile();
	});	
	
		$(".validate").delegate(
				'a',
				'click',
				function(){
					if(openClose == 0){
			           $(".hideOrShowdiv").css("display","block");
			           openClose=1;
					}else{
						$(".hideOrShowdiv").css("display","none");
				        openClose=0;
					}
		});	
	
	

	function getMobile(){
		
		var mobile = $("#mobile").val();
		$(".validate").css("display","block");
		$("#validateBtn").css("display","none");
	    var memberId = $("#memberId").val();
	    run();
	    alert("mobile--------->"+mobile);
		alert("memberId--------->"+memberId);
		var saveUrl = "smsRecord/save.do";
		$.ajax({
					url : saveUrl,
					dataType : 'text',
					data : {
						mobile:mobile,
						memberId:memberId
					},
					cache : false,

					success : function(data) {
						if(data=="success"){
							alert("验证码发送成功！！");
						}
					},
					error : function(html) {
						alert("验证码发送失败！！");
						return;
					}
				});

	}
	function run(){
		interval = setInterval(fun,time);//去掉引号就对了
		}
	function fun(){
		if(second>=0){
			$("#codeTipeClock").text(second+"秒后重新获取");
			second--;
		}else{
			$("#validateBtn").text("重新获取短信验证码");
			$("#codeTipeClock").text("");
			$("#validateBtn").css("display","block");
			$(".validate").css("display","none");
			$(".hideOrShowdiv").css("display","none");
			clearTimeout(interval);
			second=90;
			}
	}

});




function hideMobile(){
	var mobile = $("#mobile").val();
	var hideMobile = mobile.substring(0,3) + "****" + mobile.substring(7, mobile.length);
	$("#hideMobile").append(hideMobile);
}

